package org.pjlib.shadow;

import android.annotation.SuppressLint;
import android.graphics.Color;
import android.view.View;

import androidx.core.view.ViewCompat;

import com.blankj.utilcode.util.SizeUtils;

public class ShadowHelper {
    @SuppressLint("WrongConstant")
    public static void setShadow(View view, int color, int bgColor,int shadowSide){
        ShadowProperty sp = new ShadowProperty()
                .setShadowColor(color)
                .setShadowDy(SizeUtils.dp2px(0.5f))
                .setShadowRadius(SizeUtils.dp2px( 3))
                .setShadowSide(shadowSide);
        ShadowViewDrawable sd = new ShadowViewDrawable(sp,bgColor, 0, 0);
        ViewCompat.setBackground(view, sd);
        ViewCompat.setLayerType(view, ViewCompat.LAYER_TYPE_SOFTWARE, null);
    }
    public static void setShadow(View view, int color, int bgColor){
        setShadow(view,color,bgColor,ShadowProperty.LEFT | ShadowProperty.RIGHT | ShadowProperty.BOTTOM);
    }
    public static void setBgWhiteShadow(View view, int color){
        setShadow(view,color, Color.WHITE,ShadowProperty.LEFT | ShadowProperty.RIGHT | ShadowProperty.BOTTOM);
    }
}
